<template>
  <div style="width: fit-content; margin: 20px">
    <p>
      <span style="font-size: 16px">
        <strong>选课权限 </strong>
      </span>
      <el-tag :type="statusStyle" size="large" style="width: max-content; font-size: 14px">{{ statusText }}</el-tag>
      <span style="font-size: 16px; margin-left:5px;">
        <strong>当前学期 </strong>
      </span>
      <el-tag :type="statusStyle" size="large" style="width: max-content; font-size: 14px">{{ currentTime }}</el-tag>
    </p>
    <p>*注意：只能看到本专业的课程，如果选课权限关闭，可选课程为空</p>

      <el-table
          ref="showTable"
          :data="showData"
          border
          stripe
          style="width: fit-content; margin-top: 10px">
          <el-table-column
                  prop="timeLabel"
                  label="节次/周次"
                  width="100"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Sunday"
                  label="星期日"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Monday"
                  label="星期一"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Tuesday"
                  label="星期二"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Wednesday"
                  label="星期三"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Thursday"
                  label="星期四"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Friday"
                  label="星期五"
                  width="150"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  prop="Saturday"
                  label="星期六"
                  width="150"
                  align="center"
          >
          </el-table-column>
<!--      <table cellpadding="0" cellspacing="0" class="clearfix bigTable" id='downloaddata' border="1px solid #ccc">-->
<!--          <el-tr v-for='(item, index) in showData'>-->
<!--              <template v-for='items in item'>-->
<!--                  <template v-for='(itemss, indexs) in items'>-->
<!--                      <el-td>{{itemss}}</el-td>-->
<!--                  </template>-->
<!--              </template>-->
<!--          </el-tr>-->
      </el-table>


    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="可选课程" name="first"></el-tab-pane>
      <el-tab-pane label="已选课程" name="second"></el-tab-pane>
      <el-tab-pane label="已修课程" name="third"></el-tab-pane>
    </el-tabs>
    <div v-if="tabName==='first'">
      <!--可选筛选表单-->
      <el-form :inline="true" class="demo-form-inline" style="margin-top: 20px"
               ref="searchForm" v-model="searchForm" >
        <el-form-item label="时间" prop="timeId" >
          <el-select v-model="searchForm.time" multiple placeholder="请选择上课时间" clearable filterable>
            <el-option
                v-for="item in timeData"
                :key="item.id"
                :label="item.show"
                :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="教室">
          <el-select v-model="searchForm.location" placeholder="请选择"
                     style="width: 100px"
                     clearable filterable>
            <el-option v-for="item in locationData"
                       :key="item.id"
                       :label="item.courseLocation"
                       :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="课程代码">
          <el-input v-model="searchForm.courseId" placeholder="课程代码"></el-input>
        </el-form-item>
        <el-form-item label="课程名称">
          <el-input v-model="searchForm.courseName" placeholder="课程名称"></el-input>
        </el-form-item>
        <el-form-item label="教师" prop="teacherId" >
          <el-select v-model="searchForm.teacherId" placeholder="请选择"
                     style="width: 200px" clearable filterable>
            <el-option
                v-for="item in teacherData"
                :key="item.id"
                :label="item.name+'(工号：'+item.username+')'"
                :value="item.username"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="searchCourse(searchForm,userInfo.username)">搜索</el-button>
        </el-form-item>
      </el-form>
      <!--可选课程表格-->
      <el-table
          ref="courseTable"
          :data="courseData"
          border
          stripe
          >
        <el-table-column
            prop="id"
            label="课程序号"
            width="50">
        </el-table-column>
<!--        <el-table-column-->
<!--            prop="semester"-->
<!--            label="开课学期"-->
<!--            width="78">-->
<!--        </el-table-column>-->
        <el-table-column
            prop="courseId"
            label="课程编号"
            width="140">
        </el-table-column>
        <el-table-column
            prop="courseName"
            label="课程名称"
            width="100">
        </el-table-column>
        <el-table-column
            prop="type"
            label="课程类型"
            width="100">
        </el-table-column>
        <el-table-column
            prop="schoolName"
            label="授课院系"
            width="80">
        </el-table-column>
        <el-table-column
            prop="major"
            label="授课专业"
            width="80">
        </el-table-column>
        <el-table-column
            prop="credit"
            label="学分"
            width="50">
        </el-table-column>
        <el-table-column
            prop="hour"
            label="学时"
            width="50">
        </el-table-column>
        <el-table-column
            prop="time"
            label="上课时间"
            width="90">
        </el-table-column>
        <el-table-column
            prop="location"
            label="上课地点"
            width="80">
        </el-table-column>
        <el-table-column
            prop="teacher"
            label="授课教师"
            width="80">
        </el-table-column>
        <el-table-column
            v-if="false"
            prop="currentNum"
            label="已选人数"
            width=90>
        </el-table-column>
        <el-table-column
            v-if="false"
            prop="volume"
            label="课程容量"
            width=90>
        </el-table-column>
        <el-table-column
            prop="courseNum"
            label="已选人数/课程容量"
            width=90>
        </el-table-column>
        <el-table-column
            prop="intro"
            label="课程简介"
            width="200">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="操作"
            width="100">
          <template slot-scope="scope">
            <el-popconfirm title="确定要选这门课吗？" @confirm="chooseCourse(scope.row,userInfo.username)" >
              <el-button type="text" slot="reference">选课</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
    </div>
<!--    后面两个的表格还没有数据-->
<!--    包括筛选表单也暂时没有区分，是复制前面的-->
    <div v-if="tabName==='second'">
      <!--已选课程表格-->
      <el-table
          ref="courseTable"
          :data="courseChosenData"
          border
          stripe
          >
        <el-table-column
            prop="id"
            label="课程序号"
            width="50">
        </el-table-column>
        <el-table-column
            prop="semester"
            label="开课学期"
            width="78">
        </el-table-column>
        <el-table-column
            prop="courseId"
            label="课程编号"
            width="140">
        </el-table-column>
        <el-table-column
            prop="courseName"
            label="课程名称"
            width="100">
        </el-table-column>
        <el-table-column
            prop="type"
            label="课程类型"
            width="100">
        </el-table-column>
        <el-table-column
            prop="schoolName"
            label="授课院系"
            width="80">
        </el-table-column>
        <el-table-column
            prop="major"
            label="授课专业"
            width="80">
        </el-table-column>
        <el-table-column
            prop="credit"
            label="学分"
            width="50">
        </el-table-column>
        <el-table-column
            prop="hour"
            label="学时"
            width="50">
        </el-table-column>
        <el-table-column
            prop="time"
            label="上课时间"
            width="90">
        </el-table-column>
        <el-table-column
            prop="location"
            label="上课地点"
            width="80">
        </el-table-column>
        <el-table-column
            prop="teacher"
            label="授课教师"
            width="80">
        </el-table-column>
        <el-table-column
            prop="courseNum"
            label="已选人数/课程容量"
            width=90>
        </el-table-column>
        <el-table-column
            prop="intro"
            label="课程简介"
            width="200">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="操作"
            width="100">
          <template slot-scope="scope">
            <el-popconfirm title="确定要退选这门课吗？" @confirm="dropCourse(scope.row,userInfo.username)" >
              <el-button type="text" slot="reference">退课</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div v-if="tabName==='third'">
      <!--已修筛选表单-->
      <el-form :inline="true" class="demo-form-inline" style="margin-top: 20px"
        v-model="searchTakenForm" ref="searchTakenForm" >
        <el-form-item label="" prop="semester" >
          <el-select v-model="searchTakenForm.semester" placeholder="开课学期" style="width: 120px"
                     clearable filterable>
            <el-option
                v-for="item in semesterData"
                :key="item.id"
                :label="item.season"
                :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="searchTakenCourse(searchTakenForm,userInfo.username)">搜索</el-button>
        </el-form-item>
      </el-form>
      <!--已修课程表格-->
      <el-table
          ref="courseTable"
          :data="courseTakenData"
          border
          stripe
          >
        <el-table-column
            prop="id"
            label="课程序号"
            width="50">
        </el-table-column>
        <el-table-column
            prop="semester"
            label="开课学期"
            width="78">
        </el-table-column>
        <el-table-column
            prop="courseId"
            label="课程编号"
            width="140">
        </el-table-column>
        <el-table-column
            prop="courseName"
            label="课程名称"
            width="100">
        </el-table-column>
        <el-table-column
            prop="type"
            label="课程类型"
            width="100">
        </el-table-column>
        <el-table-column
            prop="schoolName"
            label="授课院系"
            width="80">
        </el-table-column>
        <el-table-column
            prop="major"
            label="授课专业"
            width="80">
        </el-table-column>
        <el-table-column
            prop="credit"
            label="学分"
            width="50">
        </el-table-column>
        <el-table-column
            prop="hour"
            label="学时"
            width="50">
        </el-table-column>
        <el-table-column
            prop="time"
            label="上课时间"
            width="90">
        </el-table-column>
        <el-table-column
            prop="location"
            label="上课地点"
            width="80">
        </el-table-column>
        <el-table-column
            prop="teacher"
            label="授课教师"
            width="80">
        </el-table-column>
        <el-table-column
            prop="intro"
            label="课程简介"
            width="200">
        </el-table-column>
      </el-table>
    </div>


  </div>
</template>

<script>
export default {
  name: "StuCourse",
  data() {
    return {
      //表格数据
      showData:[
          [{
             key1:"星期日",
             key2:"星期一",
             key3:"星期二",
             key4:"星期三",
             key5:"星期四",
             key6:"星期五",
             key7:"星期六",
          }],
      ],
      courseData: [],
      courseChosenData: [],
      courseTakenData: [],
      teacherData:[],
      // 搜索相关
      searchForm: {},
      searchTakenForm: {},
      timeData: [],
      locationData: [],

      //选课状态文字
      statusText:"",
      //选课状态样式
      statusStyle:"",


      //时间相关
      currentTime:'',
      currentSeason:'',
      currentYear:'',
      currentMonth:'',

      //标签页相关
      activeName: 'first',//初始亮着的页面
      tabName: 'first',

      userInfo:{},
      // timeLine:[
      //     {
      //         timeLabel:"第一节"
      //     },
      //     {
      //         timeLabel:"第二节"
      //     },
      //     {
      //         timeLabel:"第三节"
      //     },
      //     {
      //         timeLabel:"第四节"
      //     },
      //     {
      //         timeLabel:"第五节"
      //     },
      //     {
      //         timeLabel:"第六节"
      //     },
      //     {
      //         timeLabel:"第七节"
      //     },
      //     {
      //         timeLabel:"第八节"
      //     },
      //     {
      //         timeLabel:"第九节"
      //     },
      //     {
      //         timeLabel:"第十节"
      //     },
      //     {
      //         timeLabel:"第十一节"
      //     },
      //     {
      //         timeLabel:"第十二节"
      //     },
      //     {
      //         timeLabel:"第十三节"
      //     },
      // ]
    }
  },
  created() {
    this.getCourseStatus();
    this.getSemesterList();
    this.getTimeList();
    this.getCurrentTime();
    this.getLocationList();
    this.getTeacherList();
    this.getUserInfo()

    this.getCourseList();
    this.getChosenCourseList();
    this.getTakenCourseList();
  },
  mounted() {
  },
  methods: {
    getUserInfo() {
      this.$axios.get('/sys/user/currentInfo').then(res =>{
        this.userInfo = res.data.data;
        // console.log("个人信息：!!",this.userInfo)
      })
    },
    //获取当前选课状态
    getCourseStatus(){
      this.$axios.get('sys/user/switch/get').then(res => {
        // console.log("状态是:",res.data.data)
        this.courseStatus = res.data.data;
        //关闭
        if(res.data.data === 0){
          this.statusText="关闭"
          this.statusStyle="danger"
        }
        //一轮选课
        else if(res.data.data=== 1){
          this.statusText="一轮选课"
          this.statusStyle="success"
        }
        //二轮选课
        else if(res.data.data=== 2){
          this.statusText="二轮选课"
          this.statusStyle="success"
        }
        else{
          this.statusText="未设置"
          this.statusStyle="info"
        }
      })
    },
    //获取学期
    getSemesterList() {
      this.$axios.get('/sys-semester/listAll').then(res =>{
        // console.log("学期数据:",res.data.data)
        this.semesterData = res.data.data;
      })
    },
    //获取时间列表
    getTimeList(){
      this.$axios.get("/sys/time/listAll").then(res => {
        // console.log('TimeList',res.data.data)
        this.timeData = res.data.data;
      })
    },
    //获取当前时间
    getCurrentTime(){
      var aData = new Date();
      // console.log("时间",aData) //Wed Aug 21 2019 10:00:58 GMT+0800 (中国标准时间)
      // console.log(this.value) //2019-8-20
      this.currentYear = aData.getFullYear();
      this.currentMonth = aData.getMonth();
      if(this.currentMonth > 8){
        this.currentSeason = "秋";
      }else if(this.currentMonth > 6){
        this.currentSeason = "暑";
      }else{
        this.currentSeason = "春";
      }
      this.currentTime = this.currentYear + this.currentSeason;

    },
    //获取地点列表
    getLocationList(){
      this.$axios.get("/sys/location/list").then(res => {
        this.locationData = res.data.data;
      })
    },
    //获取地点列表
    getTeacherList(){
      this.$axios.get("/sys/user/teacherList").then(res => {
        this.teacherData= res.data.data;
      })
    },
    //分标签页用的
    handleClick(tab, event) {
      this.tabName = tab.name;
    },

    //处理课程信息的统一方法
    //输入返回值，输出处理好的数组
    getCourseData(res){
      var dataArray=[];
      for (var i=0;i<res.data.data.length;i++) {
        var data={}
        var key;
        var mapTime=[],mapSemester=[],mapLocation=[],mapMajor=[]
        data.id = res.data.data[i].id
        for (key in res.data.data[i].semester){
          mapSemester.push(res.data.data[i].semester[key])
          mapSemester.push(',')
        }
        mapSemester.pop()
        data.semester=mapSemester
        data.courseId = res.data.data[i].courseId
        data.courseName = res.data.data[i].courseName
        data.type = (res.data.data[i].type===0)?'通选课程':'专选课程';

        data.schoolName = res.data.data[i].schoolName;
        for (key in res.data.data[i].major){
          mapMajor.push(res.data.data[i].major[key])
          mapMajor.push(',')
        }
        mapMajor.pop()
        data.major = mapMajor;
        data.credit = res.data.data[i].credit;
        data.hour = res.data.data[i].hour;
        for (var key in res.data.data[i].time){
          mapTime.push(res.data.data[i].time[key])
          mapTime.push(',')
        }
        mapTime.push()
        data.time=mapTime
        data.timeId=res.data.data[i].time

        // for (var key in res.data.data[i].location){
        //     mapLocation.push(res.data.data[i].location[key])
        //     mapLocation.push(',')
        // }
        // mapLocation.pop()
        // data.location = mapLocation
        if (res.data.data[i].location!==null) {
          data.location = res.data.data[i].location.courseLocation
        }
        data.teacher = res.data.data[i].teacher;
        data.teacherId = res.data.data[i].teacherId;
        data.intro = res.data.data[i].intro;
        data.volume = res.data.data[i].volume;
        data.currentNum = res.data.data[i].currentNum;
        data.courseNum = data.currentNum + '/' + data.volume;
        dataArray.push(data);
      }
      return dataArray;
    },

    //获取可选课程列表
    getCourseList() {
      this.$axios.get('/sys/user/currentInfo').then(res1 => {
        var stuId = res1.data.data.username;
        // this.$axios.post('/sys/course/search',{}).then(res => {
        this.$axios.post('/sys/course/search',{
          username: stuId,
          statu:this.courseStatus,
        }).then(res => {
          this.courseData=this.getCourseData(res);
          // console.log("可选课程",this.courseData);
        })
      })
    },
    //获取已选课程列表
    getChosenCourseList() {
      this.$axios.get('/sys/user/currentInfo').then(res1 =>{
        var stuId = res1.data.data.username;
        var show=[];
        var course1={},course2={},course3={},course4={},course5={},course6={},course7={},course8={},course9={},course10={},course11={},course12={},course13={};
          course1.timeLabel='第一节';
          course2.timeLabel='第二节';
          course3.timeLabel='第三节';
          course4.timeLabel='第四节';
          course5.timeLabel='第五节';
          course6.timeLabel='第六节';
          course7.timeLabel='第七节';
          course8.timeLabel='第八节';
          course9.timeLabel='第九节';
          course10.timeLabel='第十节';
          course11.timeLabel='第十一节';
          course12.timeLabel='第十二节';
          course13.timeLabel='第十三节';
            this.$axios({url:'/sys/course/stu/chosen',method:"get",params:{username:stuId}}).then(res => {
            this.courseChosenData = this.getCourseData(res);
            console.log("已选课程", this.courseChosenData)
            for (var i = 0; i < this.courseChosenData.length; i++) {
                // var courseTime={}
                for (var key in this.courseChosenData[i].timeId) {
                    // var weekday=Math.floor(key/13)+1
                    // var timeC=key-weekday*13+13
                    //
                    // console.log('weekday',weekday)
                    // console.log('timeC',timeC)
                    // console.log('courseTime',courseTime)
                    // switch (key) {
                    //     case 7:
                    //         courseTime.Sunday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    //     case 1:
                    //         courseTime.Monday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    //     case 2:
                    //         courseTime.Tuesday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    //     case 3:
                    //         courseTime.Wednesday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    //     case 4:
                    //         courseTime.Thursday = this.courseChosenData[i].courseName+'\n'+this.courseChosenData[i].location;break;
                    //     case 5:
                    //         courseTime.Friday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    //     case 6:
                    //         courseTime.Saturday = this.courseChosenData[i].courseName+"("+this.courseChosenData[i].location+")";break;
                    // }
                    // switch (timeC) {
                    //     case 1:
                    //         course1 = courseTime;break;
                    //     case 2:
                    //         course2 = courseTime;break;
                    //     case 3:
                    //         course3 = courseTime;break;
                    //     case 4:
                    //         course4 = courseTime;break;
                    //     case 5:
                    //         course5 = courseTime;break;
                    //     case 6:
                    //         course6 = courseTime;break;
                    //     case 7:
                    //         course7 = courseTime;break;
                    //     case 8:
                    //         course8 = courseTime;break;
                    //     case 9:
                    //         course9 = courseTime;break;
                    //     case 10:
                    //         course10 = courseTime;break;
                    //     case 11:
                    //         course11 = courseTime;break;
                    //     case 12:
                    //         course12 = courseTime;break;
                    //     case 13:
                    //         course13 = courseTime;break;
                    // }
                    switch (key) {
                        case '1':
                            course1.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '2':
                            course2.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '3':
                            course3.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '4':
                            course4.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '5':
                            course5.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '6':
                            course6.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '7':
                            course7.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '8':
                            course8.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '9':
                            course9.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '10':
                            course10.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '11':
                            course11.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '12':
                            course12.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '13':
                            course13.Monday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '14':
                            course1.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '15':
                            course2.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '16':
                            course3.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '17':
                            course4.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '18':
                            course5.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '19':
                            course6.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '20':
                            course7.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '21':
                            course8.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '22':
                            course9.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '23':
                            course10.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '24':
                            course11.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '25':
                            course12.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '26':
                            course13.Tuesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '27':
                            course1.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '28':
                            course2.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '29':
                            course3.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '30':
                            course4.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '31':
                            course5.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '32':
                            course6.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '33':
                            course7.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '34':
                            course8.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '35':
                            course9.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '36':
                            course10.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '37':
                            course11.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '38':
                            course12.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '39':
                            course13.Wednesday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '40':
                            course1.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '41':
                            course2.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '42':
                            course3.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '43':
                            course4.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '44':
                            course5.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '45':
                            course6.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '46':
                            course7.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '47':
                            course8.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '48':
                            course9.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '49':
                            course10.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '50':
                            course11.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '51':
                            course12.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '52':
                            course13.Thursday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '53':
                            course1.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '54':
                            course2.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '55':
                            course3.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '56':
                            course4.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '57':
                            course5.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '58':
                            course6.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '59':
                            course7.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '60':
                            course8.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '61':
                            course9.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '62':
                            course10.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '63':
                            course11.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '64':
                            course12.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                        case '65':
                            course13.Friday = this.courseChosenData[i].courseName + "(" + this.courseChosenData[i].location + ")";
                            break;
                    }
                }
            }
        })

          setTimeout(()=>{

          show.push(course1)
          show.push(course2)
          show.push(course3)
          show.push(course4)
          show.push(course5)
          show.push(course6)
          show.push(course7)
          show.push(course8)
          show.push(course9)
          show.push(course10)
          show.push(course11)
          show.push(course12)
          show.push(course13)
          this.showData=show
          // console.log('showData',this.showData)
          },100)
      })
    },
    //获取已修课程列表
    getTakenCourseList() {
      this.$axios.get('/sys/user/currentInfo').then(res1 => {
        var stuId = res1.data.data.username;
        this.$axios({url:'/sys/course/stu/taken',method:"get",params:{username:stuId}}).then(res => {
          this.courseTakenData=this.getCourseData(res);
          // console.log("已修课程",this.courseTakenData);
        })
      })
    },

    //搜索可选课程
    searchCourse(formName,stuId){
      // this.$refs[formName].validate((valid) => {
        // if (valid) {
          this.searchForm.username = stuId;
          this.$axios.post('sys/course/search', this.searchForm).then(res => {
            this.courseData=this.getCourseData(res);
            console.log("搜索结果：",this.courseData);
            this.$message({
              showClose: true,
              message: '搜索成功',
              type: 'success',
              onClose: () => {
                this.resetForm(formName);
              }
            });
          })
      //   } else {
      //     console.log('error submit!');
      //     return false;
      //   }
      // });
    },
    //搜索已修课程
    searchTakenCourse(formName,stuId){
      // this.$refs[formName].validate((valid) => {
        // if (valid) {
          this.searchTakenForm.username = stuId;
          this.$axios({
              url:'/sys/course/stu/taken',
              method: "GET",
              params:{
                  username:stuId,
                  semester:this.searchTakenForm.semester
              },
          }).then(res => {
            this.courseTakenData=this.getCourseData(res);
              // console.log("搜索结果：",this.courseData);
              this.$message({
                showClose: true,
                message: '搜索成功',
                type: 'success',
                onClose: () => {
                  this.resetForm(formName);
                }
              });
          })
        // } else {
        //   console.log('error submit!');
        //   return false;
        // }
      // });
    },
    resetForm(formName){
      this.$refs[formName].resetFields();
      this.$refs[formName] = {}
    },
    //选课
    chooseCourse(row,stuId){
      // 这里要加个二轮选课的权限我还没加
      // console.log("这列课程数据",row);
      if(row.currentNum >= row.volume && this.courseStatus===2){
        this.$message({
          showClose: true,
          message: '人数已满，不可选择',
          type: 'danger',
          onClose: () => {
            //暂时没有解决数组push pop的问题
            this.getCourseList()
          }
        });
      }else{
        this.$axios.post('sys/course/choose',{id:row.id,username:stuId}).then(res => {
          // console.log('选课后返回的信息',res.data)
          this.$message({
            showClose: true,
            message: '选课成功',
            type: 'success',
            onClose: () => {
              this.getCourseList()
            }
          });
        })
      }
    },
    //退课
    dropCourse(row,stuId){
      // 这里要加个二轮选课的权限我还没加
      // console.log("这列课程数据",row);
      this.$axios.post('sys/course/stu/drop',{id:row.id,username:stuId}).then(res => {
        // console.log('选课后返回的信息',res.data.data)
        this.$message({
          showClose: true,
          message: '退课成功',
          type: 'success',
          onClose: () => {
            this.getChosenCourseList()
          }
        });
      })
    }
  }
}
</script>

<style scoped>
.el-table{
  margin-bottom: 10px;
}
</style>